/*
 * @lc app=leetcode.cn id=429 lang=javascript
 *
 * [429] N 叉树的层序遍历
 */

// @lc code=start
/**
 * // Definition for a Node.
 * function Node(val,children) {
 *    this.val = val;
 *    this.children = children;
 * };
 */

/**
 * @param {Node|null} root
 * @return {number[][]}
 */
var levelOrder = function(root) {
  const res = []
  const queque = []
  if (root === null) {
    return res
  }
  queque.push(root)
  while (queque.length) {
    const levelCur = []
    let len=queque.length
    for (let i = 0; i < len; i++){
      let curNode = queque.shift()
      levelCur.push(curNode.val)
      for (let j = 0; j < curNode.children.length; j++){
         queque.push(curNode.children[j])
      } 
    }
    res.push(levelCur)
  }
  return res
};
// @lc code=end

